export default {
  data(){
    return{
      page: {
        pageNo: 1,
        pageSize: 10,
        total: 0,
        pageSizes: [10, 20, 30, 40],
        layout: "total, sizes, prev, pager, next, jumper",
        pagerCount: 5,
        background: true,
        get(){
          return {
            page: this.pageNo,
            size: this.pageSize
          }
        },
        getLi(){
          return {
            pageNo: this.pageNo,
            pageSize: this.pageSize
          }
        }
      },
      isEditDialogVisible: false,
      isAdd: true,
      loading:false,
      curRow: null,
    }
  },
  watch:{
    'page.pageNo'(n, o){
      this.page['current-page'] = n
    }
  },
  methods:{
    _m_tip(msg){
      this.$message.success(msg);
      this.isEditDialogVisible = false;
      this._c_query();
    },
    _c_query() {
      this.$set(this.page, 'pageNo', 1)
      this._i_query();
    },
    _c_update(row) {
      this.editForm = _.cloneDeep(row);
      this.isAdd = false;
      this.isEditDialogVisible = true;
      
      this.curRow = row
    },
    _c_delete(row, $index) {
      this.curRow = row
      this.$confirm('确认删除吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(res => {
          this._i_delete(row, $index);
        },res => {}
      );
    },
    _c_page_change(val) {
      this.page.pageNo = val;
      this._i_query();
    },
    _c_add(row){
      this.$set(this, 'editForm', this.$options.data().editForm)
      this.isAdd=true;
      this.isEditDialogVisible=true;
      this.curRow = row
    },
    _c_confirm(isAdd){
      isAdd? this._i_add():this._i_update()
    },
  }
}